﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using evepctlib;

namespace Interface_WinForm
{
	public partial class Form1 : Form
	{

		public static string Version = "0.1";


		private readonly Dictionary<string, Double> _prix = new Dictionary<string, double>();
		private Double _multiplicateur = 0;

		private Int64[] _qVeldspar = new Int64[3];
		private Int64[] _qScordite = new Int64[3];
		private Int64[] _qPyroxeres = new Int64[3];
		private Int64[] _qPlagioclase = new Int64[3];
		private Int64[] _qOmber = new Int64[3];
		private Int64[] _qKernite = new Int64[3];
		private Int64[] _qJaspet = new Int64[3];
		private Int64[] _qHemorphite = new Int64[3];
		private Int64[] _qHedbergite = new Int64[3];
		private Int64[] _qGneiss = new Int64[3];
		private Int64[] _qDarkOchre = new Int64[3];
		private Int64[] _qSpodumain = new Int64[3];
		private Int64[] _qCrokite = new Int64[3];
		private Int64[] _qBistot = new Int64[3];
		private Int64[] _qArkonor = new Int64[3];
		private Int64[] _qMercoxit = new Int64[3];
		
		public Form1()
		{
			InitializeComponent();

			_prix.Add("Veldspar", 0);
			_prix.Add("Scordite", 0);
			_prix.Add("Pyroxeres", 0);
			_prix.Add("Plagioclase", 0);
			_prix.Add("Omber", 0);
			_prix.Add("Kernite", 0);
			_prix.Add("Jaspet", 0);
			_prix.Add("Hemorphite", 0);
			_prix.Add("Hedbergite", 0);
			_prix.Add("Gneiss", 0);
			_prix.Add("Dark Ochre", 0);
			_prix.Add("Spodumain", 0);
			_prix.Add("Crokite", 0);
			_prix.Add("Bistot", 0);
			_prix.Add("Arkonor", 0);
			_prix.Add("Mercoxit", 0);

			var oreChartManager = new OreChartManager();
            var prix = oreChartManager.Read();

            for (int i = 0; i < prix["Veldspar"].Count; i++)
            {
                chartVeldspar.Series[0].Points.AddXY(i, prix["Veldspar"][i]);
            }
			_prix["Veldspar"] = prix["Veldspar"].Last();
			
            for (int i = 0; i < prix["Scordite"].Count; i++)
            {
                chartScordite.Series[0].Points.AddXY(i, prix["Scordite"][i]);
            }
			_prix["Scordite"] = prix["Scordite"].Last();
			
            for (int i = 0; i < prix["Pyroxeres"].Count; i++)
            {
                chartPyroxeres.Series[0].Points.AddXY(i, prix["Pyroxeres"][i]);
            }
			_prix["Pyroxeres"] = prix["Pyroxeres"].Last();
			
            for (int i = 0; i < prix["Plagioclase"].Count; i++)
            {
                chartPlagioclase.Series[0].Points.AddXY(i, prix["Plagioclase"][i]);
            }
			_prix["Plagioclase"] = prix["Plagioclase"].Last();
			
            for (int i = 0; i < prix["Omber"].Count; i++)
            {
                chartOmber.Series[0].Points.AddXY(i, prix["Omber"][i]);
            }
			_prix["Omber"] = prix["Omber"].Last();
			
            for (int i = 0; i < prix["Kernite"].Count; i++)
            {
                chartKernite.Series[0].Points.AddXY(i, prix["Kernite"][i]);
            }
			_prix["Kernite"] = prix["Kernite"].Last();
			
            for (int i = 0; i < prix["Jaspet"].Count; i++)
            {
                chartJaspet.Series[0].Points.AddXY(i, prix["Jaspet"][i]);
            }
			_prix["Jaspet"] = prix["Jaspet"].Last();
			
            for (int i = 0; i < prix["Hemorphite"].Count; i++)
            {
                chartHemorphite.Series[0].Points.AddXY(i, prix["Hemorphite"][i]);
            }
			_prix["Hemorphite"] = prix["Hemorphite"].Last();
			
            for (int i = 0; i < prix["Hedbergite"].Count; i++)
            {
                chartHedbergite.Series[0].Points.AddXY(i, prix["Hedbergite"][i]);
            }
			_prix["Hedbergite"] = prix["Hedbergite"].Last();
			
            for (int i = 0; i < prix["Gneiss"].Count; i++)
            {
                chartGneiss.Series[0].Points.AddXY(i, prix["Gneiss"][i]);
            }
			_prix["Gneiss"] = prix["Gneiss"].Last();
			
            for (int i = 0; i < prix["Dark Ochre"].Count; i++)
            {
                chartDarkOchre.Series[0].Points.AddXY(i, prix["Dark Ochre"][i]);
            }
			_prix["Dark Ochre"] = prix["Dark Ochre"].Last();
			
            for (int i = 0; i < prix["Spodumain"].Count; i++)
            {
                chartSpodumain.Series[0].Points.AddXY(i, prix["Spodumain"][i]);
            }
			_prix["Spodumain"] = prix["Spodumain"].Last();
			
            for (int i = 0; i < prix["Crokite"].Count; i++)
            {
                chartCrokite.Series[0].Points.AddXY(i, prix["Crokite"][i]);
            }
			_prix["Crokite"] = prix["Crokite"].Last();
			
            for (int i = 0; i < prix["Bistot"].Count; i++)
            {
                chartBistot.Series[0].Points.AddXY(i, prix["Bistot"][i]);
            }
			_prix["Bistot"] = prix["Bistot"].Last();
			
            for (int i = 0; i < prix["Arkonor"].Count; i++)
            {
                chartArkonor.Series[0].Points.AddXY(i, prix["Arkonor"][i]);
            }
			_prix["Arkonor"] = prix["Arkonor"].Last();
			
            for (int i = 0; i < prix["Mercoxit"].Count; i++)
            {
                chartMercoxit.Series[0].Points.AddXY(i, prix["Mercoxit"][i]);
            }
			_prix["Mercoxit"] = prix["Mercoxit"].Last();
			
		}


		private void MajTotal()
		{
			Int64 total = 0;
			double qtotal = 0;
			total += Convert.ToInt64(lblVeldspar.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblVeldspar5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblVeldspar10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblScordite.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblScordite5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblScordite10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPyroxeres.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPyroxeres5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPyroxeres10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPlagioclase.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPlagioclase5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblPlagioclase10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblOmber.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblOmber5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblOmber10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblKernite.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblKernite5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblKernite10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblJaspet.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblJaspet5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblJaspet10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHemorphite.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHemorphite5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHemorphite10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHedbergite.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHedbergite5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblHedbergite10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblGneiss.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblGneiss5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblGneiss10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblDarkOchre.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblDarkOchre5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblDarkOchre10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblSpodumain.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblSpodumain5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblSpodumain10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblCrokite.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblCrokite5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblCrokite10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblBistot.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblBistot5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblBistot10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblArkonor.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblArkonor5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblArkonor10.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblMercoxit.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblMercoxit5.Text.Replace(" ISK", ""));
			total += Convert.ToInt64(lblMercoxit10.Text.Replace(" ISK", ""));

			qtotal += (_qVeldspar[0] + _qVeldspar[1] + _qVeldspar[2])*0.1;
			qtotal += (_qScordite[0] + _qScordite[1] + _qScordite[2]) * 0.15;
			qtotal += (_qPyroxeres[0] + _qPyroxeres[1] + _qPyroxeres[2]) * 0.3;
			qtotal += (_qPlagioclase[0] + _qPlagioclase[1] + _qPlagioclase[2]) * 0.35;
			qtotal += (_qOmber[0] + _qOmber[1] + _qOmber[2]) * 0.6;
			qtotal += (_qKernite[0] + _qKernite[1] + _qKernite[2]) * 1.2;
			qtotal += (_qJaspet[0] + _qJaspet[1] + _qJaspet[2]) * 2;
			qtotal += (_qHemorphite[0] + _qHemorphite[1] + _qHemorphite[2]) * 3;
			qtotal += (_qHedbergite[0] + _qHedbergite[1] + _qHedbergite[2]) * 3;
			qtotal += (_qGneiss[0] + _qGneiss[1] + _qGneiss[2]) * 5;
			qtotal += (_qDarkOchre[0] + _qDarkOchre[1] + _qDarkOchre[2]) * 8;
			qtotal += (_qSpodumain[0] + _qSpodumain[1] + _qSpodumain[2]) * 16;
			qtotal += (_qCrokite[0] + _qCrokite[1] + _qCrokite[2]) * 16;
			qtotal += (_qBistot[0] + _qBistot[1] + _qBistot[2]) * 16;
			qtotal += (_qArkonor[0] + _qArkonor[1] + _qArkonor[2]) * 16;
			qtotal += (_qMercoxit[0] + _qMercoxit[1] + _qMercoxit[2]) * 40;


			total = Convert.ToInt64(total*_multiplicateur);

			// mise au format "1 000"
			var sTotal = String.Format("{0:N0}", total);
			var sQTotal = String.Format("{0:N0}", qtotal);

			if (comboBox1.SelectedIndex == -1)
			{
				lblTotal.Text = @"TOTAL : Veuillez sélectionner un lieu de livraison.";
			}
			else
			{
				lblTotal.Text = @"TOTAL : " + sTotal + @" ISK";
			}

			lblVolume.Text = @"Volume : " + sQTotal + @" m3";
			
		}


		private void tbVeldspar_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbVeldspar.Text);
				var prix = Math.Round(quantité * _prix["Veldspar"]);
				
				lblVeldspar.Text = prix + @" ISK";

				_qVeldspar[0] = quantité;
			}
			catch (Exception)
			{
				tbVeldspar.Text = string.Empty;
				lblVeldspar.Text = @"0 ISK";
				_qVeldspar[0] = 0;
			}
			MajTotal();
		}

		private void tbVeldspar5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbVeldspar5.Text);
				var prix = Math.Round((quantité * _prix["Veldspar"]) + ((quantité * _prix["Veldspar"]) * 0.05));
				
				lblVeldspar5.Text = prix + @" ISK";

				_qVeldspar[1] = quantité;
			}
			catch (Exception)
			{
				tbVeldspar5.Text = string.Empty;
				lblVeldspar5.Text = @"0 ISK";
				_qVeldspar[1] = 0;
			}
			MajTotal();
		}

		private void tbVeldspar10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbVeldspar10.Text);
				var prix = Math.Round((quantité * _prix["Veldspar"]) + ((quantité * _prix["Veldspar"]) * 0.1));

				lblVeldspar10.Text = prix + @" ISK";

				_qVeldspar[2] = quantité;
			}
			catch (Exception)
			{
				tbVeldspar10.Text = string.Empty;
				lblVeldspar10.Text = @"0 ISK";
				_qVeldspar[2] = 0;
			}
			MajTotal();
		}

		private void tbScordite_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbScordite.Text);
				var prix = Math.Round(quantité * _prix["Scordite"]);

				lblScordite.Text = prix + @" ISK";

				_qScordite[0] = quantité;
			}
			catch (Exception)
			{
				tbScordite.Text = string.Empty;
				lblScordite.Text = @"0 ISK";
				_qScordite[0] = 0;
			}
			MajTotal();
		}

		private void tbScordite5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbScordite5.Text);
				var prix = Math.Round((quantité * _prix["Scordite"]) + ((quantité * _prix["Scordite"]) * 0.05));

				lblScordite5.Text = prix + @" ISK";

				_qScordite[1] = quantité;
			}
			catch (Exception)
			{
				tbScordite5.Text = string.Empty;
				lblScordite5.Text = @"0 ISK";
				_qScordite[1] = 0;
			}
			MajTotal();
		}

		private void tbScordite10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbScordite10.Text);
				var prix = Math.Round((quantité * _prix["Scordite"]) + ((quantité * _prix["Scordite"]) * 0.1));

				lblScordite10.Text = prix + @" ISK";

				_qScordite[2] = quantité;
			}
			catch (Exception)
			{
				tbScordite10.Text = string.Empty;
				lblScordite10.Text = @"0 ISK";
				_qScordite[2] = 0;
			}
			MajTotal();
		}

		private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
		{
			switch(comboBox1.SelectedIndex)
			{
				case 0:
					// Inari
					_multiplicateur = 1;
					lblMultiplicateur.ForeColor = Color.LightGreen;
					lblMultiplicateur.Text = @"QG - 100% du prix";
					break;
				case 1:
				// Jita
					_multiplicateur = 0.75;
					lblMultiplicateur.ForeColor = Color.Salmon;
					lblMultiplicateur.Text = @"Lieu préférentiel - 75% du prix";
					break;
				default:
					// Autre
					_multiplicateur = 0.5;
					lblMultiplicateur.ForeColor = Color.OrangeRed;
					lblMultiplicateur.Text = @"Lieu inconnu - 50% du prix";
					break;
			}
			MajTotal();
		}

		private void tbPyroxeres_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPyroxeres.Text);
				var prix = Math.Round(quantité * _prix["Pyroxeres"]);

				lblPyroxeres.Text = prix + @" ISK";

				_qPyroxeres[0] = quantité;
			}
			catch (Exception)
			{
				tbPyroxeres.Text = string.Empty;
				lblPyroxeres.Text = @"0 ISK";
				_qPyroxeres[0] = 0;
			}
			MajTotal();
		}

		private void tbPyroxeres5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPyroxeres5.Text);
				var prix = Math.Round((quantité * _prix["Pyroxeres"]) + ((quantité * _prix["Pyroxeres"]) * 0.05));

				lblPyroxeres5.Text = prix + @" ISK";

				_qPyroxeres[1] = quantité;
			}
			catch (Exception)
			{
				tbPyroxeres5.Text = string.Empty;
				lblPyroxeres5.Text = @"0 ISK";
				_qPyroxeres[1] = 0;
			}
			MajTotal();
		}

		private void tbPyroxeres10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPyroxeres10.Text);
				var prix = Math.Round((quantité * _prix["Pyroxeres"]) + ((quantité * _prix["Pyroxeres"]) * 0.1));

				lblPyroxeres10.Text = prix + @" ISK";

				_qPyroxeres[2] = quantité;
			}
			catch (Exception)
			{
				tbPyroxeres10.Text = string.Empty;
				lblPyroxeres10.Text = @"0 ISK";
				_qPyroxeres[2] = 0;
			}
			MajTotal();
		}

		private void tbPlagioclase_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPlagioclase.Text);
				var prix = Math.Round(quantité * _prix["Plagioclase"]);

				lblPlagioclase.Text = prix + @" ISK";

				_qPlagioclase[0] = quantité;
			}
			catch (Exception)
			{
				tbPlagioclase.Text = string.Empty;
				lblPlagioclase.Text = @"0 ISK";
				_qPlagioclase[0] = 0;
			}
			MajTotal();
		}

		private void tbPlagioclase5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPlagioclase5.Text);
				var prix = Math.Round((quantité * _prix["Plagioclase"]) + ((quantité * _prix["Plagioclase"]) * 0.05));

				lblPlagioclase5.Text = prix + @" ISK";

				_qPlagioclase[1] = quantité;
			}
			catch (Exception)
			{
				tbPlagioclase5.Text = string.Empty;
				lblPlagioclase5.Text = @"0 ISK";
				_qPlagioclase[1] = 0;
			}
			MajTotal();
		}

		private void tbPlagioclase10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbPlagioclase10.Text);
				var prix = Math.Round((quantité * _prix["Plagioclase"]) + ((quantité * _prix["Plagioclase"]) * 0.1));

				lblPlagioclase10.Text = prix + @" ISK";

				_qPlagioclase[2] = quantité;
			}
			catch (Exception)
			{
				tbPlagioclase10.Text = string.Empty;
				lblPlagioclase10.Text = @"0 ISK";
				_qPlagioclase[2] = 0;
			}
			MajTotal();
		}

		private void tbOmber_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbOmber.Text);
				var prix = Math.Round(quantité * _prix["Omber"]);

				lblOmber.Text = prix + @" ISK";

				_qOmber[0] = quantité;
			}
			catch (Exception)
			{
				tbOmber.Text = string.Empty;
				lblOmber.Text = @"0 ISK";
				_qOmber[0] = 0;
			}
			MajTotal();
		}

		private void tbOmber5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbOmber5.Text);
				var prix = Math.Round((quantité * _prix["Omber"]) + ((quantité * _prix["Omber"]) * 0.05));

				lblOmber5.Text = prix + @" ISK";

				_qOmber[1] = quantité;
			}
			catch (Exception)
			{
				tbOmber5.Text = string.Empty;
				lblOmber5.Text = @"0 ISK";
				_qOmber[1] = 0;
			}
			MajTotal();
		}

		private void tbOmber10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbOmber10.Text);
				var prix = Math.Round((quantité * _prix["Omber"]) + ((quantité * _prix["Omber"]) * 0.1));

				lblOmber10.Text = prix + @" ISK";

				_qOmber[2] = quantité;
			}
			catch (Exception)
			{
				tbOmber10.Text = string.Empty;
				lblOmber10.Text = @"0 ISK";
				_qOmber[2] = 0;
			}
			MajTotal();
		}

		private void tbKernite_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbKernite.Text);
				var prix = Math.Round(quantité * _prix["Kernite"]);

				lblKernite.Text = prix + @" ISK";

				_qKernite[0] = quantité;
			}
			catch (Exception)
			{
				tbKernite.Text = string.Empty;
				lblKernite.Text = @"0 ISK";
				_qKernite[0] = 0;
			}
			MajTotal();
		}

		private void tbKernite5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbKernite5.Text);
				var prix = Math.Round((quantité * _prix["Kernite"]) + ((quantité * _prix["Kernite"]) * 0.05));

				lblKernite5.Text = prix + @" ISK";

				_qKernite[1] = quantité;
			}
			catch (Exception)
			{
				tbKernite5.Text = string.Empty;
				lblKernite5.Text = @"0 ISK";
				_qKernite[1] = 0;
			}
			MajTotal();
		}

		private void tbKernite10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbKernite10.Text);
				var prix = Math.Round((quantité * _prix["Kernite"]) + ((quantité * _prix["Kernite"]) * 0.1));

				lblKernite10.Text = prix + @" ISK";

				_qKernite[2] = quantité;
			}
			catch (Exception)
			{
				tbKernite10.Text = string.Empty;
				lblKernite10.Text = @"0 ISK";
				_qKernite[2] = 0;
			}
			MajTotal();
		}

		private void tbJaspet_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbJaspet.Text);
				var prix = Math.Round(quantité * _prix["Jaspet"]);

				lblJaspet.Text = prix + @" ISK";

				_qJaspet[0] = quantité;
			}
			catch (Exception)
			{
				tbJaspet.Text = string.Empty;
				lblJaspet.Text = @"0 ISK";
				_qJaspet[0] = 0;
			}
			MajTotal();
		}

		private void tbJaspet5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbJaspet5.Text);
				var prix = Math.Round((quantité * _prix["Jaspet"]) + ((quantité * _prix["Jaspet"]) * 0.05));

				lblJaspet5.Text = prix + @" ISK";

				_qJaspet[1] = quantité;
			}
			catch (Exception)
			{
				tbJaspet5.Text = string.Empty;
				lblJaspet5.Text = @"0 ISK";
				_qJaspet[1] = 0;
			}
			MajTotal();
		}

		private void tbJaspet10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbJaspet10.Text);
				var prix = Math.Round((quantité * _prix["Jaspet"]) + ((quantité * _prix["Jaspet"]) * 0.1));

				lblJaspet10.Text = prix + @" ISK";

				_qJaspet[2] = quantité;
			}
			catch (Exception)
			{
				tbJaspet10.Text = string.Empty;
				lblJaspet10.Text = @"0 ISK";
				_qJaspet[2] = 0;
			}
			MajTotal();
		}

		private void tbHemorphite_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHemorphite.Text);
				var prix = Math.Round(quantité * _prix["Hemorphite"]);

				lblHemorphite.Text = prix + @" ISK";

				_qHemorphite[0] = quantité;
			}
			catch (Exception)
			{
				tbHemorphite.Text = string.Empty;
				lblHemorphite.Text = @"0 ISK";
				_qHemorphite[0] = 0;
			}
			MajTotal();
		}

		private void tbHemorphite5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHemorphite5.Text);
				var prix = Math.Round((quantité * _prix["Hemorphite"]) + ((quantité * _prix["Hemorphite"]) * 0.05));

				lblHemorphite5.Text = prix + @" ISK";

				_qHemorphite[1] = quantité;
			}
			catch (Exception)
			{
				tbHemorphite5.Text = string.Empty;
				lblHemorphite5.Text = @"0 ISK";
				_qHemorphite[1] = 0;
			}
			MajTotal();
		}

		private void tbHemorphite10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHemorphite10.Text);
				var prix = Math.Round((quantité * _prix["Hemorphite"]) + ((quantité * _prix["Hemorphite"]) * 0.1));

				lblHemorphite10.Text = prix + @" ISK";

				_qHemorphite[2] = quantité;
			}
			catch (Exception)
			{
				tbHemorphite10.Text = string.Empty;
				lblHemorphite10.Text = @"0 ISK";
				_qHemorphite[2] = 0;
			}
			MajTotal();
		}

		private void tbHedbergite_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHedbergite.Text);
				var prix = Math.Round(quantité * _prix["Hedbergite"]);

				lblHedbergite.Text = prix + @" ISK";

				_qHedbergite[0] = quantité;
			}
			catch (Exception)
			{
				tbHedbergite.Text = string.Empty;
				lblHedbergite.Text = @"0 ISK";
				_qHedbergite[0] = 0;
			}
			MajTotal();
		}

		private void tbHedbergite5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHedbergite5.Text);
				var prix = Math.Round((quantité * _prix["Hedbergite"]) + ((quantité * _prix["Hedbergite"]) * 0.05));

				lblHedbergite5.Text = prix + @" ISK";

				_qHedbergite[1] = quantité;
			}
			catch (Exception)
			{
				tbHedbergite5.Text = string.Empty;
				lblHedbergite5.Text = @"0 ISK";
				_qHedbergite[1] = 0;
			}
			MajTotal();
		}

		private void tbHedbergite10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbHedbergite10.Text);
				var prix = Math.Round((quantité * _prix["Hedbergite"]) + ((quantité * _prix["Hedbergite"]) * 0.1));

				lblHedbergite10.Text = prix + @" ISK";

				_qHedbergite[2] = quantité;
			}
			catch (Exception)
			{
				tbHedbergite10.Text = string.Empty;
				lblHedbergite10.Text = @"0 ISK";
				_qHedbergite[2] = 0;
			}
			MajTotal();
		}

		private void tbGneiss_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbGneiss.Text);
				var prix = Math.Round(quantité * _prix["Gneiss"]);

				lblGneiss.Text = prix + @" ISK";

				_qGneiss[0] = quantité;
			}
			catch (Exception)
			{
				tbGneiss.Text = string.Empty;
				lblGneiss.Text = @"0 ISK";
				_qGneiss[0] = 0;
			}
			MajTotal();
		}

		private void tbGneiss5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbGneiss5.Text);
				var prix = Math.Round((quantité * _prix["Gneiss"]) + ((quantité * _prix["Gneiss"]) * 0.05));

				lblGneiss5.Text = prix + @" ISK";

				_qGneiss[1] = quantité;
			}
			catch (Exception)
			{
				tbGneiss5.Text = string.Empty;
				lblGneiss5.Text = @"0 ISK";
				_qGneiss[1] = 0;
			}
			MajTotal();
		}

		private void tbGneiss10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbGneiss10.Text);
				var prix = Math.Round((quantité * _prix["Gneiss"]) + ((quantité * _prix["Gneiss"]) * 0.1));

				lblGneiss10.Text = prix + @" ISK";

				_qGneiss[2] = quantité;
			}
			catch (Exception)
			{
				tbGneiss10.Text = string.Empty;
				lblGneiss10.Text = @"0 ISK";
				_qGneiss[2] = 0;
			}
			MajTotal();
		}

		private void tbDarkOchre_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbDarkOchre.Text);
				var prix = Math.Round(quantité * _prix["Dark Ochre"]);

				lblDarkOchre.Text = prix + @" ISK";

				_qDarkOchre[0] = quantité;
			}
			catch (Exception)
			{
				tbDarkOchre.Text = string.Empty;
				lblDarkOchre.Text = @"0 ISK";
				_qDarkOchre[0] = 0;
			}
			MajTotal();
		}

		private void tbDarkOchre5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbDarkOchre5.Text);
				var prix = Math.Round((quantité * _prix["Dark Ochre"]) + ((quantité * _prix["Dark Ochre"]) * 0.05));

				lblDarkOchre5.Text = prix + @" ISK";

				_qDarkOchre[1] = quantité;
			}
			catch (Exception)
			{
				tbDarkOchre5.Text = string.Empty;
				lblDarkOchre5.Text = @"0 ISK";
				_qDarkOchre[1] = 0;
			}
			MajTotal();
		}

		private void tbDarkOchre10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbDarkOchre10.Text);
				var prix = Math.Round((quantité * _prix["Dark Ochre"]) + ((quantité * _prix["Dark Ochre"]) * 0.1));

				lblDarkOchre10.Text = prix + @" ISK";

				_qDarkOchre[2] = quantité;
			}
			catch (Exception)
			{
				tbDarkOchre10.Text = string.Empty;
				lblDarkOchre10.Text = @"0 ISK";
				_qDarkOchre[2] = 0;
			}
			MajTotal();
		}

		private void tbSpodumain_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbSpodumain.Text);
				var prix = Math.Round(quantité * _prix["Spodumain"]);

				lblSpodumain.Text = prix + @" ISK";

				_qSpodumain[0] = quantité;
			}
			catch (Exception)
			{
				tbSpodumain.Text = string.Empty;
				lblSpodumain.Text = @"0 ISK";
				_qSpodumain[0] = 0;
			}
			MajTotal();
		}

		private void tbSpodumain5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbSpodumain5.Text);
				var prix = Math.Round((quantité * _prix["Spodumain"]) + ((quantité * _prix["Spodumain"]) * 0.05));

				lblSpodumain5.Text = prix + @" ISK";

				_qSpodumain[1] = quantité;
			}
			catch (Exception)
			{
				tbSpodumain5.Text = string.Empty;
				lblSpodumain5.Text = @"0 ISK";
				_qSpodumain[1] = 0;
			}
			MajTotal();
		}

		private void tbSpodumain10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbSpodumain10.Text);
				var prix = Math.Round((quantité * _prix["Spodumain"]) + ((quantité * _prix["Spodumain"]) * 0.1));

				lblSpodumain10.Text = prix + @" ISK";

				_qSpodumain[2] = quantité;
			}
			catch (Exception)
			{
				tbSpodumain10.Text = string.Empty;
				lblSpodumain10.Text = @"0 ISK";
				_qSpodumain[2] = 0;
			}
			MajTotal();
		}

		private void tbCrokite_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbCrokite.Text);
				var prix = Math.Round(quantité * _prix["Crokite"]);

				lblCrokite.Text = prix + @" ISK";

				_qCrokite[0] = quantité;
			}
			catch (Exception)
			{
				tbCrokite.Text = string.Empty;
				lblCrokite.Text = @"0 ISK";
				_qCrokite[0] = 0;
			}
			MajTotal();
		}

		private void tbCrokite5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbCrokite5.Text);
				var prix = Math.Round((quantité * _prix["Crokite"]) + ((quantité * _prix["Crokite"]) * 0.05));

				lblCrokite5.Text = prix + @" ISK";

				_qCrokite[1] = quantité;
			}
			catch (Exception)
			{
				tbCrokite5.Text = string.Empty;
				lblCrokite5.Text = @"0 ISK";
				_qCrokite[1] = 0;
			}
			MajTotal();
		}

		private void tbCrokite10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbCrokite10.Text);
				var prix = Math.Round((quantité * _prix["Crokite"]) + ((quantité * _prix["Crokite"]) * 0.1));

				lblCrokite10.Text = prix + @" ISK";

				_qCrokite[2] = quantité;
			}
			catch (Exception)
			{
				tbCrokite10.Text = string.Empty;
				lblCrokite10.Text = @"0 ISK";
				_qCrokite[2] = 0;
			}
			MajTotal();
		}

		private void tbBistot_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbBistot.Text);
				var prix = Math.Round(quantité * _prix["Bistot"]);

				lblBistot.Text = prix + @" ISK";

				_qBistot[0] = quantité;
			}
			catch (Exception)
			{
				tbBistot.Text = string.Empty;
				lblBistot.Text = @"0 ISK";
				_qBistot[0] = 0;
			}
			MajTotal();
		}

		private void tbBistot5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbBistot5.Text);
				var prix = Math.Round((quantité * _prix["Bistot"]) + ((quantité * _prix["Bistot"]) * 0.05));

				lblBistot5.Text = prix + @" ISK";

				_qBistot[1] = quantité;
			}
			catch (Exception)
			{
				tbBistot5.Text = string.Empty;
				lblBistot5.Text = @"0 ISK";
				_qBistot[1] = 0;
			}
			MajTotal();
		}

		private void tbBistot10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbBistot10.Text);
				var prix = Math.Round((quantité * _prix["Bistot"]) + ((quantité * _prix["Bistot"]) * 0.1));

				lblBistot10.Text = prix + @" ISK";

				_qBistot[2] = quantité;
			}
			catch (Exception)
			{
				tbBistot10.Text = string.Empty;
				lblBistot10.Text = @"0 ISK";
				_qBistot[2] = 0;
			}
			MajTotal();
		}

		private void tbArkonor_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbArkonor.Text);
				var prix = Math.Round(quantité * _prix["Arkonor"]);

				lblArkonor.Text = prix + @" ISK";

				_qArkonor[0] = quantité;
			}
			catch (Exception)
			{
				tbArkonor.Text = string.Empty;
				lblArkonor.Text = @"0 ISK";
				_qArkonor[0] = 0;
			}
			MajTotal();
		}

		private void tbArkonor5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbArkonor5.Text);
				var prix = Math.Round((quantité * _prix["Arkonor"]) + ((quantité * _prix["Arkonor"]) * 0.05));

				lblArkonor5.Text = prix + @" ISK";

				_qArkonor[1] = quantité;
			}
			catch (Exception)
			{
				tbArkonor5.Text = string.Empty;
				lblArkonor5.Text = @"0 ISK";
				_qArkonor[1] = 0;
			}
			MajTotal();
		}

		private void tbArkonor10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbArkonor10.Text);
				var prix = Math.Round((quantité * _prix["Arkonor"]) + ((quantité * _prix["Arkonor"]) * 0.1));

				lblArkonor10.Text = prix + @" ISK";

				_qArkonor[2] = quantité;
			}
			catch (Exception)
			{
				tbArkonor10.Text = string.Empty;
				lblArkonor10.Text = @"0 ISK";
				_qArkonor[2] = 0;
			}
			MajTotal();
		}

		private void tbMercoxit_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbMercoxit.Text);
				var prix = Math.Round(quantité * _prix["Mercoxit"]);

				lblMercoxit.Text = prix + @" ISK";

				_qMercoxit[0] = quantité;
			}
			catch (Exception)
			{
				tbMercoxit.Text = string.Empty;
				lblMercoxit.Text = @"0 ISK";
				_qMercoxit[0] = 0;
			}
			MajTotal();
		}

		private void tbMercoxit5_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbMercoxit5.Text);
				var prix = Math.Round((quantité * _prix["Mercoxit"]) + ((quantité * _prix["Mercoxit"]) * 0.05));

				lblMercoxit5.Text = prix + @" ISK";

				_qMercoxit[1] = quantité;
			}
			catch (Exception)
			{
				tbMercoxit5.Text = string.Empty;
				lblMercoxit5.Text = @"0 ISK";
				_qMercoxit[1] = 0;
			}
			MajTotal();
		}

		private void tbMercoxit10_TextChanged(object sender, EventArgs e)
		{
			try
			{
				Int64 quantité = Convert.ToInt64(tbMercoxit10.Text);
				var prix = Math.Round((quantité * _prix["Mercoxit"]) + ((quantité * _prix["Mercoxit"]) * 0.1));

				lblMercoxit10.Text = prix + @" ISK";

				_qMercoxit[2] = quantité;
			}
			catch (Exception)
			{
				tbMercoxit10.Text = string.Empty;
				lblMercoxit10.Text = @"0 ISK";
				_qMercoxit[2] = 0;
			}
			MajTotal();
		}

	}
}
